<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>企业客户</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.7 -->
    <!--link导入外部的css，js样式，如果导入的资源和本页面在同一个文件夹下，直接文件名即可-->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/bootstrap/dist/css/bootstrap.min.css}">
    <!-- jQuery 3 -->
    <script th:src="@{/asserts/bower_components/jquery/dist/jquery.min.js}"></script>
    <!-- Bootstrap 3.3.7 -->
    <script th:src="@{/asserts/bower_components/bootstrap/dist/js/bootstrap.min.js}"></script>
    <!-- Font Awesome -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/font-awesome/css/font-awesome.min.css}">
    <!-- Ionicons -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/Ionicons/css/ionicons.min.css}">
    <!-- DataTables -->
    <link rel="stylesheet" th:href="@{/asserts/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css}">
    <!-- Theme style -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/AdminLTE.min.css}">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" th:href="@{/asserts/dist/css/skins/_all-skins.min.css}">
    <!--联想查询-->
    <script th:src="@{/asserts/Apolar_sh/lib/js/bigautocomplete.js}"></script>
    <link rel="stylesheet" th:href="@{/asserts/Apolar_sh/lib/css/bigautocomplete.css}" type="text/css"/>
    <script th:src="@{/asserts/Apolar_sh/lib/layer/2.4/layer.js}"></script>

    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->

    <!-- Google Font -->
    <link rel="stylesheet"
          href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
    <style type="text/css">
        .search {
            margin-top: 40px;
            margin-left: 40px;
            position: relative;
        }

        td {
            text-align: center;
        }

        th {
            text-align: center;
        }
    </style>

</head>
<body>


<div class="wrapper">
    <!-- Content Wrapper. Contains page content -->
    <!-- Content Header (Page header) -->
    <!-- Main content -->
    <section class="content-header">
        <h4 th:text="|${coName}:其他合作成果列表|">
        </h4>

    </section>
    <div class="search" style="margin-top: 15px;">
        <div class="row">
            <div class="col-xs-2">
                <a th:if="${info == null}" class="btn btn-info"
                   th:href="@{/cr/saveOtherUI(coId=${coId},coName=${coName},currentPage=${pageBean.pageNum},pageNow=${pageNow})}">
                    <i class="fa fa-plus"></i> 添加其他合作成果
                </a>
                <a th:if="${info != null}" class="btn btn-info"
                   th:href="@{/cr/saveOtherUI(coId=${coId},coName=${coName},pageNow=${pageNow})}">
                    <i class="fa fa-plus"></i> 添加其他合作成果
                </a>
            </div>
            <div class="col-md-2">
                <a class="btn btn-info" th:href="@{/company/findAll(currentPage=${pageNow})}">
                    <i class="fa fa-backward"></i> 返回
                </a>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </div>

    <!-- /.content -->
</div>
<p></p>
<div class="wrapper">
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-xs-12">
                <div class="box">
                    <div th:if="${info != null}" style="width: 270px;margin: auto">
                        <p style="color: #ff0000;font-size: 30px;font-weight: bold">[[${info}]]</p>
                    </div>
                    <!-- /.box-header 部门列表的显示  table  表格  th/td单元个   th字体加粗，行标题-->
                    <div class="box-body" th:if="${info == null}">
                        <form method="post"
                              th:action="@{/cr/deleteAllOther(coId=${coId},coName=${coName},currentPage=${pageBean.pageNum},pageNow=${pageNow})}">
                            <table id="example1" class="table table-bordered table-hover">
                                <tbody>
                                <tr>
                                    <th th:if="${session.user.authority != 3}">选择</th>
                                    <th>其他说明</th>
                                    <th>操作</th>
                                </tr>
                                <tr th:each="result:${pageBean.list}">
                                    <td th:if="${session.user.authority != 3}">
                                        <input type="checkbox" id="check" name="crIds" class="checks"
                                               th:value="${result.crId}"/>
                                    </td>
                                    <td th:text="${result.crRemark}" style="width:80%;">其他说明。。。。。。。。。。。。。。。。。</td>
                                    <td>
                                        <a class="btn btn-warning"
                                           th:href="@{/cr/updateOtherUI(coId=${coId},coName=${coName},crId=${result.crId},currentPage=${pageBean.pageNum},pageSize=${pageBean.pageSize},pageNow=${pageNow})}">
                                            <i class="fa fa-edit"></i> 修改
                                        </a>
                                        <!--<a id="delete" class="btn btn-danger" th:if="${session.user.authority != 3}"-->
                                        <!--th:href="@{/cr/deleteOtherById(crId=${result.crId},coId=${coId},coName=${coName},pageNow=${pageNow})}"-->
                                        <!--onclick="return confirm('确认要删除？')">-->
                                        <!--<i class="fa fa-trash"></i> 删除-->
                                        <!--</a>-->
                                        <a class="btn btn-danger"
                                           th:onclick="deleteById([[${result.crId}]],[[${coId}]],[[${coName}]],[[${pageNow}]])"
                                           th:if="${session.user.authority != 3}">
                                            <i class="fa fa-trash"></i> 删除
                                        </a>
                                    </td>
                                </tr>

                                <tr>
                                    <td th:if="${session.user.authority != 3}">
                                        <label><input type="checkbox" name="" id="all" value=""/>&nbsp;&nbsp;全选</label>
                                    </td>
                                    <td colspan="13" style="text-align:left;padding-left:20px;">
                                        <button th:if="${session.user.authority != 3}" class="btn btn-danger"
                                                onclick="return confirm('确认要删除？')" type="submit">
                                            <i class="fa fa-trash"></i> 删除
                                        </button>
                                    </td>
                                </tr>
                                </tbody>
                            </table>
                        </form>
                        <!-- 分页 -->
                        <nav aria-label="Page navigation">
                            <ul class="pagination">
                                <li>
                                    <a th:if="${pageBean.pageNum != 1 && searchUrl == null}"
                                       th:href="@{/cr/findOther(coId=${coId},coName=${coName},currentPage=1,pageNow=${pageNow})}">首页</a>
                                    <a th:if="${pageBean.pageNum != 1 && searchUrl != null}"
                                       th:href="@{${searchUrl}(coName=${coName},sname=${sname},currentPage=1,pageNow=${pageNow})}">首页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==1 }"
                                       href="javascript:void(0)">首页</a>
                                </li>

                                <li th:if="${pageBean.pageNum!=1 && searchUrl == null }">
                                    <a th:href="@{/cr/findOther(coId=${coId},coName=${coName},currentPage=${pageBean.pageNum-1},pageNow=${pageNow})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=1 && searchUrl != null }">
                                    <a th:href="@{${searchUrl}(coName=${coName},sname=${sname},currentPage=${pageBean.pageNum-1},pageNow=${pageNow})}"
                                       aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>
                                <li class="disabled" th:if="${pageBean.pageNum==1 }">
                                    <a href="javascript:void(0)" aria-label="Previous">
                                        <span aria-hidden="true">&laquo;</span>
                                    </a>
                                </li>

                                <li th:classappend="${pageBean.pageNum==pageIndex}?'active':''"
                                    th:each="pageIndex:${pageValue}">
                                    <a
                                            th:if="${pageBean.pageNum==pageIndex}"
                                            th:text="${pageIndex}"></a>
                                    <a th:if="${pageIndex==-1}" style="cursor: default;opacity: 0.6;">
                                        ...
                                    </a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchUrl == null }"
                                       th:href="@{/cr/findOther(coId=${coId},coName=${coName},currentPage=${pageIndex},pageNow=${pageNow})}"
                                       th:text="${pageIndex}"></a>
                                    <a th:if="${pageBean.pageNum!=pageIndex&&pageIndex!=-1 && searchUrl != null }"
                                       th:href="@{${searchUrl}(coName=${coName},sname=${sname},currentPage=${pageIndex},pageNow=${pageNow})}"
                                       th:text="${pageIndex}"></a>
                                </li>

                                <li class="disabled" th:if="${pageBean.pageNum==pageBean.pages }">
                                    <a href="javascript:void(0)" aria-label="Next">
                                        <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchUrl == null }">
                                    <a th:href="@{/cr/findOther(coId=${coId},coName=${coName},currentPage=${pageBean.pageNum+1},pageNow=${pageNow})}"
                                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>
                                <li th:if="${pageBean.pageNum!=pageBean.pages && searchUrl != null}">
                                    <a th:href="@{${searchUrl}(coName=${coName},sname=${sname},currentPage=${pageBean.pageNum+1},pageNow=${pageNow})}"
                                       aria-label="Next"> <span aria-hidden="true">&raquo;</span>
                                    </a>
                                </li>

                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchUrl == null}"
                                       th:href="@{/cr/findOther(coId=${coId},coName=${coName},currentPage=${pageBean.pages},pageNow=${pageNow})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum!=pageBean.pages && searchUrl != null }"
                                       th:href="@{${searchUrl}(coName=${coName},sname=${sname},currentPage=${pageBean.pages},pageNow=${pageNow})}">末页</a>
                                </li>
                                <li>
                                    <a th:if="${pageBean.pageNum==pageBean.pages }"
                                       href="javascript:void(0)">末页</a>
                                </li>

                            </ul>
                        </nav>
                        <input id="currentPage" th:value="${pageBean.pageNum}" hidden>
                        <input id="currentPageSize" th:value="${pageBean.size}" hidden>
                        <input id="lastPage" th:value="${pageBean.pages}" hidden>
                    </div>
                    <!-- /.box-body -->
                </div>
                <!-- /.box -->
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
</div>

<!-- ./wrapper -->


<!-- DataTables -->
<script th:src="@{/asserts/bower_components/datatables.net/js/jquery.dataTables.min.js}"></script>
<script th:src="@{/asserts/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js}"></script>
<!-- SlimScroll -->
<script th:src="@{/asserts/bower_components/jquery-slimscroll/jquery.slimscroll.min.js}"></script>
<!-- FastClick -->
<script th:src="@{/asserts/bower_components/fastclick/lib/fastclick.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/asserts/dist/js/adminlte.min.js}"></script>
<!-- AdminLTE for demo purposes -->
<script th:src="@{/asserts/dist/js/demo.js}"></script>
<!-- page script -->
<script>
    $("#all").click(function () {
        if (this.checked) {
            $(".checks").prop("checked", true);
            $("#all").prop("value", "全不选");
        } else {
            $(".checks").prop("checked", false);
            $("#all").prop("value", "全选");
        }
    });

    function deleteById(crId, coId, coName, pageNow) {
        layer.confirm("确认删除？",
            {
                btn: ['确定', '取消'] //按钮
            },
            function () {
                var currentPageSize = $("#currentPageSize").val();
                var currentPage = $("#currentPage").val();
                var lastPage = $("#lastPage").val();
                $.ajax({
                    url: '[[${#httpServletRequest.getContextPath()}]]/cr/deleteOtherById?currentPageSize=' + currentPageSize + '&currentPage=' + currentPage + '&lastPage=' + lastPage,
                    data: {
                        'crId': crId
                    },
                    success: function (result) {
                        console.log(result);
                        if (result == '1') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.reload();
                        } else if (result == '0') {
                            layer.msg('删除成功！', {icon: 1, time: 1000});
                            location.replace("[[${#httpServletRequest.getContextPath()}]]/cr/findOther?coId=" + coId + "&coName=" + coName + "&currentPage=" + (currentPage - 1) + "&pageNow=" + pageNow);
                        }
                        else {
                            layer.msg('删除失败！', {icon: 0, time: 2000});
                        }

                    }
                })
            },
            function () {
                layer.msg('已取消！', {icon: 0, time: 500});
                return false;
            }
        );
    };
</script>
</body>
</html>